package com.groupseven.happycampus.common.instener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.groupseven.happycampus.common.bo.ParttimeHolidayBo;
import com.groupseven.happycampus.common.pojo.ParttimeHoliday;
import com.groupseven.happycampus.service.ParttimeHolidayService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

/**
 * @CreateTime: 2022-07-26  21:41
 */
@Component
@Scope("prototype")
public class WebParttimeHolidayListener extends AnalysisEventListener<ParttimeHolidayBo> {

    @Autowired
    ParttimeHolidayService parttimeHolidayService;

    @Override
    public void invoke(ParttimeHolidayBo data, AnalysisContext analysisContext) {
        System.out.println(data);
        ParttimeHoliday parttimeHoliday = new ParttimeHoliday();
        BeanUtils.copyProperties(data, parttimeHoliday);
        parttimeHolidayService.insertParttimeHoliday(parttimeHoliday);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
